home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6031 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  34 lines

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: URGENT HELP in declaring arrays of strings
  5. Date: 21 Feb 1996 13:30:21 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4gg2tdINN3c3@keats.ugrad.cs.ubc.ca>
  8. References: <4gb1a1$l3v@reader2.ix.netcom.com>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4gb1a1$l3v@reader2.ix.netcom.com>,
  12. SPD <spdcool@ix.netcom.com> wrote:
  13.  >Hi,
  14.  >names.  That is why I need to know how to assign an array of strings in
  15.  >my assignment.  IF I'm wrong in what I think I have to to, please
  16.  >correct me.  Thanks alot in advance.
  17.  
  18. Hand this in (diligently extending it to 15 names first): It assigns the
  19. strings in array N to array M by copying the pointers.
  20.  
  21.     #define X "Amy","Joe","Bob","Suzy","Mike","Sean","Cathy","Matt",0
  22.     int main(int argc,char**argv){char*N[]={X};char*M[sizeof(N)/sizeof(*N)];
  23.     char**p=N;int i=0;for(;*p;p++,i++)i[M]=*p;return 0;}
  24.  
  25. Either that, or tell them that arrays can't be assigned in C. They can undergo
  26. aggregate initialization, which is not assignment.
  27.  
  28.  >please e-mail me at spdcool@ix.netcom.com and spd7398@acf4.nyu.edu
  29.  >mail it to both address b/c I could either be in school or at home.    
  30.  
  31. How about I just FedEx it to you so you get brownie points for early hand-in?
  32. -- 
  33.  
  34.